package com.shrct.businessprocess.purchase.proxy;

import com.google.gwt.user.client.rpc.IsSerializable;
import com.shrct.businessprocess.purchase.proxy.RCServicePurchaseOrderAction;

public class RCServicePurchaseOrderManager implements IsSerializable {
  public static Boolean isActionValid(final RCServicePurchaseOrderAction action, final String state) {
    if(action==null||state==null) return false;
    switch(action){
    	case startAudit:{
    		return "craeted".equals(state);
    	}
    	case auditPassed:{
    		return "auditing".equals(state);
    	}
    	case auditCanceled:{
    		return "auditing".equals(state);
    	}
    	case invoiceRegister:{
    		return "executing".equals(state);
    	}
    	case payRequest:{
    		return "executing".equals(state);
    	}
    	case close:{
    		return "executing".equals(state);
    	}
    	case postCancel:{
    		return "executing".equals(state);
    	}
    	case cancelClose:{
    		return "closed".equals(state);
    	}
    	default:
    		return false;
    }
    
  }
  
  public static Boolean isActionValid(final RCServicePurchaseOrderAction action, final Enum<?> state) {
    return isActionValid(action,state.name());
    
  }
}
